<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>[|.pageTitle|]</title>
    [|if .zTree|]
    <link rel="stylesheet" href="/static/zTree3/css/demo.css?t=5" type="text/css">
    <link rel="stylesheet" href="/static/zTree3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    [|end|]
    <meta charset="utf-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/main.css">
    <script src="/static/layui/layui.js?s=36"></script>
    <script src="/static/js/main.js?s=2124"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
<form class="layui-form" >
    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:100px;">房间信息：</label>
      <div class="layui-input-inline">
        <select name="roomslist" id = "roomslist" lay-verify="required" lay-search="">
        </select>
      </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:100px;">执行时间：</label>
        <div class="layui-input-inline">
             <input type="text" class="layui-input" id="dateyymmdd" placeholder="yyyy-MM-dd" readonly>
        </div>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="datehhmmss" placeholder="HH:mm:ss" readonly>
      </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:100px;">血池目标配置：</label>
        <div class="layui-input-inline">
            <input type="number" name="addbloodvalues" id="addbloodvalues" autocomplete="off"  class="layui-input" value="0">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                *>0表示房间放水，<0表时房间吃分
            </font>
        </div>
    </div>
    
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="onputinsure">确定添加</button>
            <button class="layui-btn layui-btn-normal" href="/sysroomconf/list.html" lay-submit="" lay-filter="returlist">返回房间列表</button>
        </div>
    </div>
</form>
</div>

<script>
    var $;

    layui.config({
            base : "js/"
    }).use(['form','element','layer','jquery','laydate'], function(){
        var element = layui.element;
        var form = layui.form;
        var laydate = layui.laydate;
        $ = layui.jquery;
    //监听表格复选框选择
   // table.on('checkbox(demo)', function(obj){
    //   console.log(obj);
   // });

   
    GetMyXiaLaLset()

    //方法级渲染
    form.render("select")
    //常规用法
    laydate.render({
        elem: '#dateyymmdd'
        ,min: 0
    });
  //  var varTmpGetData = getNowFormatDate();
    //时间选择器
    laydate.render({
         elem: '#datehhmmss'
        ,type: 'time'
        //,min: varTmpGetData
        //,max: '23:59:59'
        ,btns: ['clear', 'confirm']
     });
  
    //监听工具条
   

    form.on('submit(onputinsure)', function(data) {
        
        var selObj = document.getElementById("roomslist");
        var dateyymmdd = document.getElementById("dateyymmdd");
        var datehhmmss = document.getElementById("datehhmmss");
        var tmpdate = dateyymmdd.value + " " +datehhmmss.value;
        var addbloodvalues = document.getElementById("addbloodvalues");
        if(dateyymmdd.value == "" )
        {
            layer.alert("请选择年月日！", {
                    title: '失败'
            }) 
            return false
        }
        if(datehhmmss.value == "" )
        {
            layer.alert("请选择时分秒！", {
                title: '失败'
            }) 
            return false
        }
        if(addbloodvalues.value == "" || addbloodvalues.value == 0)
        {
            layer.alert("添加血池值为0，请确认！", {
                    title: '失败'
            }) 
            return false
        }
        layer.confirm('您确定要添加【'+ addbloodvalues.value+'】到房间【' + selObj.value+'】么？' , function(index){
            var jsData = {
                'Room_ID':selObj.value
                ,'Ctrl_Type':1
                ,'Ctrl_DataTime':tmpdate
                ,'Add_Values':addbloodvalues.value
                }
            $.post('[|urlfor "SysRoomconfController.RoomBooldCtrl"|]', jsData, function (out) {
                if (out.status == 0) {
                    layer.alert(out.message, {icon: 1},function(index){
                        window.location.href="/sysroomconf/extermevipuseredit.html?ServerID="+selObj.value

                    });
                } else {
                    layer.msg(out.message)
                }
            }, "json");
              
            // layer.alert(JSON.stringify(jsData), {
              //      title: '最终的提交信息'
              // }) 
       
        });
        return false;
    });
    form.on('submit(returlist)', function(data) {
        window.location.href="/sysroomconf/list.html"
        return false
    });

}); 
function GetMyXiaLaLset(){
 
    var selObj = document.getElementById("roomslist");
    //var valObj = document.getElementById("val");
    //var texObj = document.getElementById("tex");
    // 关键是这几句
    var myData = [|.RoomList|]
    var curvalue = [|.curServerID|] 
    for ( var i = 0 ; i < myData.length;i ++)
    {
        var Option = document.createElement("option");
        Option.value = myData[i].ServerID;
        if(curvalue == myData[i].ServerID){
          //   layer.alert(JSON.stringify(curvalue), {
           //     title: '最终的提交信息'
           //}) 
             Option.selected="selected";
        }

        Option.text ="(" + myData[i].ServerID + ")"+ myData[i].RoomName;
        selObj.options.add(Option);
    }
}

</script>
</body>
</html>